package com.example.usercount.controller;

import com.example.usercount.dao.UserDAO;
import com.example.usercount.entity.UserEntity;
import com.example.usercount.service.UserService;
import com.example.vo.UserVIO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("user")
@Api("扣除账户相关")
@RequestMapping("users")
public class UserCountCtroller {
    @Autowired
    UserDAO userDAO;
    @Autowired
    UserService userService;
    @ApiOperation("查询用户信息")
    @GetMapping("/listuser")
    public List<UserEntity> listusers(){

        return  userDAO.getUser();
    }
    @ApiOperation("扣款")
    @PostMapping("/deductmoney")
    public boolean deductmoney(){
     return  true;
    }
    @ApiOperation("查询用户金额")
    @PostMapping("/getusercountdetails/{userID}")
    public UserVIO getusercountdetails(@PathVariable Long userID){
        return userService.getUserCountdetails(userID);
    }
    @PostMapping("/cutmoney")
    public boolean cutmoneyByUserId(@RequestBody UserVIO userVIO){

        return userService.cutmoneyByUserId(userVIO);
    }
}
